﻿using System.Collections.Generic;

namespace DesignerScripts
{
    /// <summary>
    /// 剧本的效果
    /// </summary>
    public class Screenplay
    {
        public static Dictionary<string, ScreenplayOnRoundTick> OnRoundTickFunc = new Dictionary<string, ScreenplayOnRoundTick>(){
            {"Fieldrunners", Fieldrunners}
        };
        public static Dictionary<string, ScreenplayOnCompRoundTick> OnCompRoundTickFunc = new Dictionary<string, ScreenplayOnCompRoundTick>(){
        };
        public static Dictionary<string, ScreenplayOnActionPawn> OnActionPawnFunc = new Dictionary<string, ScreenplayOnActionPawn>(){
        };
        public static Dictionary<string, ScreenplayOnKillPawn> OnKillPawnFunc = new Dictionary<string, ScreenplayOnKillPawn>(){
            {"CampPawnSurviveNum", CampPawnSurviveNum}
        };
        
        ///<summary>
        ///OnRoundTick
        /// 坚守一定回合
        ///no params
        ///</summary>
        private static void Fieldrunners(ScreenplayObj screenplayObj){
            if (screenplayObj.TimeElapsed > (int)screenplayObj.Model.OnRoundTickParams[1])
            {
               SceneVariants.GetLevelManager().EndOfLevel((bool)screenplayObj.Model.OnRoundTickParams[0]); 
            } 
        }
        
        ///<summary>
        ///OnRoundTick
        ///根据某个阵营存活判断失败还是胜利
        ///no params
        ///</summary>
        private static void CampPawnSurviveNum(ScreenplayObj screenplayObj){
            if ((bool)screenplayObj.Model.OnKillPawnParams[2] == SceneVariants.GetLevelManager().CheckCompPawnSurvival((string)screenplayObj.Model.OnKillPawnParams[1]))
            {
                SceneVariants.GetLevelManager().EndOfLevel((bool)screenplayObj.Model.OnKillPawnParams[0]);
            } 
        }
    }
}